package com.lzm.ydpt.module.mall.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import androidx.viewpager.widget.PagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class HorizontalGvPagerAdapter extends PagerAdapter {
    List<GridView> mGridViewList = new ArrayList<>();

    public HorizontalGvPagerAdapter(List<GridView> gridViewList) {
        mGridViewList.clear();
        mGridViewList.addAll(gridViewList);
    }

    @Override
    public int getCount() {
        return mGridViewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, final int position) {
        container.addView(mGridViewList.get(position));
        return mGridViewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}

